package AbstractFactory.simpleFactory;

import AbstractFactory.*;

/**
 * @author duanzhizhou
 * @date 2024/10/12
 */
public class DataAccess {
    
    private String driver;
    
    public String getDriver() {
        return driver;
    }
    
    public void setDriver(String driver) {
        this.driver = driver;
    }
    
    public IUser createUser() {
        switch(this.driver) {
            case "MySql":
                return new MySqlUser();
            case "Oracle":
                return new OracleUser();
            default:
                throw new RuntimeException("类型不支持");
        }
    }
    
    public IDepartment createIDepartment() {
        switch(this.driver) {
            case "MySql":
                return new MySqlDepartment();
            case "Oracle":
                return new OracleDepartment();
            default:
                throw new RuntimeException("类型不支持");
        }
    }
}
